/**
 * 
 */
package com.yst.metho.web.application.vacationday;

import nextapp.echo2.app.Component;
import nextapp.echo2.app.Label;
import nextapp.echo2.app.Table;
import nextapp.echo2.app.table.TableCellRenderer;

import com.yst.suivi.data.vacationday.VacationDay;

/**
 * @author perso
 * 
 */
public class VacationTableCellRenderer implements TableCellRenderer
{

	private static final int YEAR_COLUMN = 2;

	private static final int MONTH_COLUMN = 1;

	private static final int DAY_COLUMN = 0;

	/*
	 * (non-Javadoc)
	 * 
	 * @see nextapp.echo2.app.table.TableCellRenderer#getTableCellRendererComponent(nextapp.echo2.app.Table,
	 *      java.lang.Object, int, int)
	 */
	public Component getTableCellRendererComponent(Table table, Object value, int column, int row)
	{
		VacationDay vacation = (VacationDay) value;
		Label label = new Label("");
		if (null != value)
		{
			switch (column)
			{
			case DAY_COLUMN:
				label.setText(vacation.getJour().toString());
				break;
			case MONTH_COLUMN:
				label.setText(vacation.getMois().toString());
				break;
			case YEAR_COLUMN:
				label.setText(vacation.getAnnee().toString());
				break;
			default:
				label.setText("colonne inconnu : " + column);
			}
		}
		else
		{
			label.setText("null");
		}
		if (row % 2 == 0)
		{
			label.setStyleName("ListingView.EvenRowLabel");
		}
		else
		{
			label.setStyleName("ListingView.OddRowLabel");
		}
		return label;
	}

}
